<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>定时器</title>
		<script>
			  var  timer;
			  var i=1;
			  function funA(){
			  	  var obj=document.getElementById("s1");  //得到是这个对象
			      obj.innerHTML=i; 
			      i++;
			      timer=setTimeout("funA()",1000);   //递归
			  }
			  
			  function funB(){
			  	   clearTimeout(timer);
			  }
		</script>
	</head>
	<body>
		<span id="s1"></span>
		<br />
		<button  onclick="funA()">开始</button>
		<br />
		<button onclick="funB()">停止</button>
	</body>
</html>
